﻿using System.Collections.Generic;
using System.Linq;
using ZilLion.Service.Core.DapperWrapper.SqlServer;
using ZilLion.Service.TaskPlatform.Domain.Entity;
using ZilLion.Service.TaskPlatform.Domain.Respository.Interface;

namespace ZilLion.Service.TaskPlatform.Domain.Respository.Sqlserver
{
    public class NodePerformanceMonitorRespository : SqlServerRespository<NodePerformanceMonitorEntity>,
        INodePerformanceMonitorRespository
    {
        public NodePerformanceMonitorRespository()
        {
            Context = new TaskRunnerSqlserverContext();
        }

        public void AddPerformanceMonitorInfo(NodePerformanceMonitorEntity entity)
        {
            Add(entity);
        }

        public void MotifyPerformanceMonitorInfo(NodePerformanceMonitorEntity entity)
        {
            Modify(entity);
        }

        public IEnumerable<NodePerformanceMonitorEntity> GetAllNodeMonitorInfo()
        {
            return GetList("select * from node_performance_monitor");
        }

        public NodePerformanceMonitorEntity GetNodeMonitorInfoById(string nodeid)
        {
            return
                GetList("select * from node_performance_monitor where nodeid=@nodeid", new {nodeid}).FirstOrDefault();
        }
    }
}